function [D_Gumbel_M,D_Gumbel_W]=...
         param_Gumbel_closedform_MW(PYX_cond, PXY_cond, ntypes_m, ntypes_w)
%% U,V
U_Gumbel=zeros(ntypes_m,ntypes_w);
for i=1:ntypes_m
for j=1:ntypes_w
    U_Gumbel(i,j)=log(PYX_cond(i,j)/PYX_cond(i,end));  
end
end

V_Gumbel=zeros(ntypes_m,ntypes_w);
for j=1:ntypes_w
for i=1:ntypes_m
    V_Gumbel(i,j)=log(PXY_cond(j,i)/PXY_cond(j,end)); 
end
end


%% D
D_Gumbel_M=zeros(ntypes_m,ntypes_m); %here ntypes_m=ntypes_w
D_Gumbel_W=zeros(ntypes_m,ntypes_m); %here ntypes_m=ntypes_w
for i=1:ntypes_m-1
    for k=i+1:ntypes_m
        D_Gumbel_M(i,k)=U_Gumbel(i,i)+U_Gumbel(k,k)-U_Gumbel(i,k)-U_Gumbel(k,i); 
        D_Gumbel_W(i,k)=V_Gumbel(i,i)+V_Gumbel(k,k)-V_Gumbel(i,k)-V_Gumbel(k,i); 
    end
end


end

